function flushCode(object) {
    // document.getElementById("code").src = "/code?date=" + new Date();
    // object.src="/code?date=" + new Date();
    $(object).attr("src", "http://localhost:8080/code?date=" + new Date());
}

function login() {
    let username = $("#username").val();
    let password = $("#password").val();
    let code = $("#code").val();
    let reg = /^[a-zA-Z]\w{5,15}$/;
    if (!reg.test(username)) {
        alert("你输入用户名的格式不正确!");
        return;
    }
    if (!reg.test(password)) {
        alert("你输入密码的格式不正确!");
        return;
    }
    let data = myAjax("/login", {username: username, password: password, code: code}, "post")
    if (data.result == 1) {
        window.location.href = "/html/back/manage.html";
    } else if (data.result == 0) {
        alert("你输入的用户名或者密码不正确");
    } else if (data.result == -1) {
        alert("你输入的验证码不正确");
    }
    // $.ajax({
    //     url: 'http://localhost:8080/login',
    //     data: {username: username, password: password, code: code},
    //     type: 'post',
    //     dataType: 'json',
    //     success: function (data) {
    //         if (data.result == 1) {
    //             window.location.href = "/html/back/manage.html";
    //         } else if(data.result==0){
    //             alert("你输入的用户名或者密码不正确");
    //         }else if(data.result==-1){
    //             alert("你输入的验证码不正确");
    //         }
    //     }
    // })


}